package org.tio.sitexxx.web.server.controller;

import org.tio.http.common.HttpRequest;
import org.tio.http.server.annotation.RequestPath;
import org.tio.sitexxx.service.model.main.Demo;
import org.tio.sitexxx.service.service.DemoService;
import org.tio.utils.resp.Resp;

import com.jfinal.plugin.activerecord.Page;

/**
 * @author tanyaowu
 */
@RequestPath(value = "/demo")
public class DemoController {

	public DemoController() {
	}

	@RequestPath(value = "/save")
	public Resp save(Demo demo, HttpRequest request) throws Exception {
		DemoService.me.save(demo);
		return Resp.ok();
	}
	
	@RequestPath(value = "/update")
	public Resp update(Demo demo, HttpRequest request) throws Exception {
		DemoService.me.update(demo);
		return Resp.ok();
	}
	
	@RequestPath(value = "/page")
	public Resp page(Integer pageNumber, Integer pageSize, HttpRequest request) throws Exception {
		Page<Demo> page = DemoService.me.page(pageNumber, pageSize);
		return Resp.ok(page);
	}
}
